from selenium import webdriver
from selenium.webdriver.common.by import By
import time
'''
功能：访问百度，搜索高考
1. 打开浏览器
2. 访问百度网页
3. 找到搜索框，输入关键词'彭于晏’
4. 截图
'''
driver = webdriver.Chrome()  # 实例化对象
url = "http://www.baidu.com"
driver.get(url)
#   id选择器实现搜索功能
driver.find_element(By.ID,"kw").click()
driver.find_element(By.ID,"kw").send_keys("彭于晏")
driver.find_element(By.ID,"su").click()
time.sleep(5)
# 截图
driver.save_screenshot(r"d:\img\a.png")
# 退出
time.sleep(2)
driver.quit()
